<include file="public@mobileHeader"/>
<section class="ui-container homework">
    <h1 class="ui-row ui-whitespace">
        消息列表
    </h1>

    <ul class="ui-list ui-list-pure ui-border-tb">
        <notempty name="messages">
            <foreach name="messages" item="vo">
                <!--未读-->
                <if condition="$vo.msg_status neq 1">
                    <li class="ui-border-t notread">
                        <p>
                        <span>{$vo.id}.{$vo.user_name} </span>
                        <span class="date"> {:date('Y年m月d日 H:i',$vo.create_time)}</span>
                        <span class="ui-badge">new</span>
                <else>
                    <li class="ui-border-t">
                        <p>
                            <span>{$vo.id}.{$vo.user_name} </span>
                            <span class="date"> {:date('Y年m月d日 H:i',$vo.create_time)}</span>
                </if>
                        </p>
                        <h2 style="margin:5px 0;">{$vo.subject}</h2>
                        <h5>{$vo.content}</h5>
                    </li>
            </foreach>
        </notempty>
    </ul>

    <div class="pagination">{$page}</div>

</section>
<include file="public@mobileFooter"/>
<script type="text/javascript">
    $(".notread").click(function () {
        var $this=$(this);
        var msg_id=parseInt($this.find('span').text());
        var dia = $.dialog({
            title: '提示',
            content: '标记为已读吗?',
            button: ["确认", "取消"],
        });
        dia.on("dialog:action", function (e) {
            if (e.index == 0) {
                $.post('{:url("mobile/Message/ajax_read")}',{'msg_id':msg_id}, function (data) {
                    if (data.code == 1) {
                        var el = $.tips({
                            content: '已读',
                            stayTime: 2000,
                            type: "success"
                        });
                        //提示框读完之后取消触发条件class,隐藏new小图片
                        el.on("tips:hide",function(){
                            $this.removeClass('notread');
                            $this.find('.ui-badge').hide(500);
                        })
                    }
                });
            }
        });

    })
</script>